package com.xbs.controller.backstage;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xbs.controller.base.BaseServlet;
import com.xbs.entity.ConsumerEntity;
import com.xbs.service.user.ConsumerService;
import com.xbs.utils.DateJsonValueProcessor;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.CycleDetectionStrategy;


/**
 * 普通用户
 * @author Administrator
 *
 */
@WebServlet("/backstage/consumer2")
public class Consumer2Servlet extends BaseServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String idcard = req.getParameter("idcard");
		ConsumerService consumerservice = new ConsumerService();
		consumerservice.delete(idcard);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String idcard1 = req.getParameter("idcard1");
		ConsumerService consumerservice = new ConsumerService();
		List<ConsumerEntity> consumerlist = consumerservice.selAll2(idcard1);
		JsonConfig jsonConfig = new JsonConfig();   
		jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);   
		jsonConfig.registerJsonBeanProcessor(java.sql.Date.class, new DateJsonValueProcessor());  
		jsonConfig.setExcludes(new String[]{"handler","hibernateLazyInitializer"});    
		JSONObject jsonObject = JSONObject.fromObject(consumerlist.get(0),jsonConfig);
		resp.getWriter().print(jsonObject);
	}
}
